#!/usr/bin/env python
# encoding: utf-8
# @author: Lin Han
# @contact: voldemort22@126.com
# @file: models.py
# @time: 2021/3/18 14:18
# @desc:
from datetime import datetime
from enum import Enum
from typing import List, Dict, Optional

from pydantic import BaseModel


class MessageQueueInputJson(BaseModel):
    userName: str
    path: str
    state: str
    # 后续下面这个可以考虑改成uuid类型
    uid: str


class RpsType(str, Enum):
    Fix = "夹紧"
    Press = "压紧"
    Support = "支撑"
    Locate = "定位"


class FactoryStandard(str, Enum):
    Volkswagen = "大众"
    GeneralMotor = "通用"
    Bmw = "宝马"
    Volvo = "沃尔沃"


class ClampTag(BaseModel):
    # 此何物也？车身区域
    area: str
    # 此何物也？厂家标准
    standard: List[str]
    # 有多少个夹紧点
    rpsNumber: int
    # 下面的str改成enum
    rpsType: Dict[int, RpsType]
    # 气缸数量
    airNumber: int
    hasStopBlock: bool
    hasPin: bool
    elseTag: List


class PartTag(BaseModel):
    number: str
    # bigType: Optional[str]
    # pillarHeight: Optional[str]
    # category: Optional[str]
    # elseTag: Optional[List]
    # smallType: Optional[str]
    standard: Optional[str]
    version: Optional[str]
    partType: Optional[List[dict]]
    jsonAliOssAddress: Optional[str]


class Base(BaseModel):
    number: str
    isFeature: bool
    isFlag: bool
    name: str
    Time: datetime
    desc: Optional[str]
    version: Optional[str]
    # TODO: 用户名先不管，这个可能涉及到单点登录的事情
    # CUser: Optional[str]


class ClampModelBase(Base):

    ClampStpAddress: Optional[str]
    ClampStpMD5: Optional[str]
    ClampStlAddress: Optional[str]
    ClampStlMD5: Optional[str]
    ClampGltfAddress: Optional[str]
    ClampGltfMD5: Optional[str]

    # 下面工件这部分也先不加了
    WorkPieceCatPartAddress: Optional[str]
    WorkPieceCatPartMD5: Optional[str]
    WorkPieceStpAddress: Optional[str]
    WorkPieceStpMD5: Optional[str]
    WorkPieceStlAddress: Optional[str]
    WorkPieceStlMD5: Optional[str]
    WorkPieceGltfAddress: Optional[str]
    WorkPieceGltfMD5: Optional[str]

    Tag: Optional[ClampTag]


class ClampCATProductModel(ClampModelBase):
    ClampCatPartAddress: Optional[str]
    ClampCatPartMD5: Optional[str]


class ClampCATPartModel(ClampModelBase):
    ClampCatPartAddress: Optional[str]
    ClampCatPartMD5: Optional[str]


class PartModel(Base):
    PartCatPartAddress: str
    PartCatPartMD5: str

    Tag: Optional[PartTag]


class ParameterModel(PartModel):
    ParameterJson: Dict


class ResponseModel(BaseModel):
    message: str
    number: str


class ParameterResponseModel(ResponseModel):
    PartCatPartAddress: Optional[str]


class ClampResponseModel(ResponseModel):
    ClampCatPartAddress: Optional[str]


class PartResponseModel(ResponseModel):
    PartCatPartAddress: Optional[str]
